//
//  SWBarButtonItem.swift
//  SinaWeibo
//
//  Created by wszyxc on 16/7/19.
//  Copyright © 2016年 wszyxc. All rights reserved.
//

import UIKit

class SWBarButtonItem: UIBarButtonItem {
    
    
    init(title:String?,imageName:String?,target: AnyObject?, action: Selector){

        super.init()
        
        let buttonItem:UIButton = UIButton()
        
        if let tit = title{
            
            buttonItem.setTitle(tit, forState: .Normal)
            buttonItem.setTitleColor(UIColor.orangeColor(), forState: .Normal)
            buttonItem.titleLabel?.font = UIFont.systemFontOfSize(15)
        }
        
        if let img = imageName{
            
            buttonItem.setImage(UIImage(named: img), forState: .Normal)
        }
        
        buttonItem.addTarget(target, action: action, forControlEvents: .TouchUpInside)
        
        self.customView = buttonItem
        
        buttonItem.sizeToFit()
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    

}
